Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically perform swap estimation on user input #1920

Merged
merged 4 commits into from
Nov 22, 2024
Merged

Conversation

TalDerei
Copy link
Contributor

references #1919

Screen.Recording.2024-11-21.at.8.16.48.PM.mov

@TalDerei TalDerei self-assigned this Nov 22, 2024
Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: 5f052f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
minifront Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 32 to 35
<div className='relative flex items-center justify-between'>
<ValueViewComponent view={input} size='sm' />
<div className='absolute left-1/2 -translate-x-1/2 flex items-center'>
<ArrowRight size={20} strokeWidth={2.5} className='text-white' />
Copy link
Contributor Author

@TalDerei TalDerei Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: thoughts about replacing the up and down arrows with a single right arrow? the up and down arrows had alignment issues as the routes expanded


before

Screenshot 2024-11-21 at 7 49 07 PM

after

Screenshot 2024-11-21 at 7 49 33 PM

if (!disabled && amount && parseFloat(amount) > 0) {
// Prevents re-triggering the swap simulation if it's already computed
if (!result) {
void simulateSwap();
Copy link
Contributor Author

@TalDerei TalDerei Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: we can optionally wrap this in a framer motion div for smoother rendering

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be future work

@TalDerei TalDerei requested review from a team and hdevalence November 22, 2024 04:34
Copy link
Member

@hdevalence hdevalence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🚀

Comment on lines +30 to +35
<div className='flex w-full justify-between gap-8'>
{trace.value.map((value, index) => (
<div key={index} className='flex shrink-0 flex-col gap-1'>
<div
key={index}
className='flex min-w-[60px] max-w-[150px] shrink-0 grow basis-auto flex-col items-center gap-1'
>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tightening pill to dynamically shrink and fit within the available space


before

Screenshot 2024-11-21 at 10 48 58 PM

after

Swaps are filed in descending order of price to get you the best possible trade for your tokens

@TalDerei TalDerei merged commit 29ceb15 into main Nov 22, 2024
6 checks passed
@TalDerei TalDerei deleted the swap-estimate branch November 22, 2024 06:59
const { simulateSwap, resetSimulateSwap, disabled, result, amount } =
useStoreShallow(simulateSwapSelector);

useEffect(() => {
Copy link
Collaborator

@grod220 grod220 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical to fix, but in the future, we should always see if it's possible to use react-query first (versus useEffect()) for all async tasks. The complexities of loading/error/cache invalidation is abstracted away.

Copy link
Contributor Author

@TalDerei TalDerei Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally, forgot about using react-query here – that's an easy refactor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants